Prover: Invalid Transactions
Proves that a transaction was malformed. This involves attempting to parse the transaction leaf.
A valid transaction proof, proof
, must be provided.
- Get the transaction leaf component of the proof,
leaf = proof.transaction
. - Metadata count
leaf.metadata.length
must be less than0
or more thanINPUTS_MAX
. - As a sanity check, witnesses length in bytes
leaf.witnesses.length
must be less than0
or more thanTRANSACTION_SIZE_MAX
. Same for inputs lengthleaf.inputs.length
and outputs lengthleaf.outputs.length
. - The leaf length
leaf.length
must be at less thanTRANSACTION_SIZE_MIN
or more thanTRANSACTION_SIZE_MAX
. - The leaf total length
leaf.length+2
(since theleaf.length
field itself is2
bytes) must not match that size of the leaf component of the proof.
The witnesses are parsed:
- For each witness, shift by the length of the witness:
- If the witness type is
Caller
:- The transaction ID from the witness registry at the witness ID must be
0
(i.e. the witness has not bee registered). - The block number of the witness must be at least the block number in
proof
(i.e. the witness was not registered strictly before the block was committed).
- The transaction ID from the witness registry at the witness ID must be
- If the witness type is
- The number of parsed witnesses must be greater than
INPUTS_MAX
. - The parsed length of witnesses must not match
leaf.witnesses.length
.
The inputs are parsed:
- For each input, shift by the length of the input:
- The input type must be out of bounds.
- The witness reference index
input.witnessIndex
must be out of bounds (i.e. at least the number of witnesses).
- The number of parsed inputs must be greater than
INPUTS_MAX
. - The parsed length of inputs must not match
leaf.inputs.length
.
The outputs are parsed:
- For each output, shift by the length of the output:
- The output type must be out of bounds.
- If the output type is
Transfer
,Withdraw
, orHTLC
:- The output token and amount fields must be out of bounds.
- The output owner field must be out of bounds.
- If the output type is
HTLC
:- the output return owner field must be out of bounds.
- If the output type is
Return
:- The data length must be out of bounds.
- The number of parsed outputs must be greater than
OUTPUTS_MAX
. - The parsed length of outputs must not match
leaf.outputs.length
.
The sizes are parsed:
- The number of metadata elements must not match the number of inputs.
The metadata are parsed:
- For each metadata, shift by the length of the metadata:
- The metadata fields must be out of bounds.
- The parsed length of metadata must not match
leaf.metadata.length
.